import {useGetSystemInfoSyncPlatform, useWChartMiniProgramsPlatform} from "@/utils/tools";

const platform = useGetSystemInfoSyncPlatform();
const WChartMiniProgramsPlatform = platform === "mp-weixin" ? useWChartMiniProgramsPlatform() : "develop";

// 微信小程序
const WChartMiniProgramsApi: Record<string, Record<string, string>> = {
    // 开发版
    develop: {
        base: "https://assetmanagement-gw-test.000982.net",
        local: "http://localhost:8888"
    },
    // 体验版
    trial: {
        base: "https://assetmanagement-gw-test.000982.net"
    },
    // 正式版
    release: {
        base: "https://assetmanagement-gw-pro.000982.net"
    }
};

// H5
const H5Api: Record<string, Record<string, string>> = {
    // 开发环境
    development: {
        base: "https://assetmanagement-h5-test.000982.net",
        local: "http://localhost:8888"
    },
    // 正式环境
    production: {
        base: "https://assetmanagement-h5-pro.000982.net",
        local: "http://localhost:8888"
    }
};

const matchPlatformApi: Record<string, () => Record<string, string>> = {
    "mp-weixin": () => WChartMiniProgramsApi[WChartMiniProgramsPlatform] || WChartMiniProgramsApi["develop"],
    "web": () => H5Api[import.meta.env.MODE] || H5Api["development"]
};

export const BASE_URL = matchPlatformApi[platform]()["base"];
export const LOCAL_URL = matchPlatformApi[platform]()["local"];
